package cn.kgm.genericity.interfaces.impl;

import cn.kgm.genericity.GenericityClass;

/**
 * Create by kappi on
 * 2021/12/23/023 17:05
 */
public class GeneratorImpl {

    static GenericityClass<Integer> gInteger = new GenericityClass<Integer>(123);
    static GenericityClass<Number> gNumber = new GenericityClass<Number>(456);

    public static void main(String[] args) throws InstantiationException, IllegalAccessException {
        showKeyValue(gNumber,Thread.class);
        showKeyValue(gInteger,Thread.class);
    }
    // 只能传Number和Number的子类
    public static void showKeyValue(GenericityClass<? extends Number> obj,Class<Thread> threadClass) throws InstantiationException, IllegalAccessException {
        Thread thread = threadClass.newInstance();
        System.out.println(obj.getInit());
    }
    // 只能传integer和integer的父类
    public static  void showKeyValue2(GenericityClass<? super Integer> obj){
        System.out.println(obj.getInit());
    }
}
